package cn.iocoder.yudao.module.product.dal.mysql.categoryPlatform;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.product.dal.dataobject.categoryPlatform.CategoryPlatformDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.product.controller.admin.categoryPlatform.vo.*;

/**
 * 平台商品分类 Mapper
 *
 * @author sqalong
 */
@Mapper
public interface CategoryPlatformMapper extends BaseMapperX<CategoryPlatformDO> {

    default List<CategoryPlatformDO> selectList(CategoryPlatformListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CategoryPlatformDO>()
                .eqIfPresent(CategoryPlatformDO::getParentId, reqVO.getParentId())
                .likeIfPresent(CategoryPlatformDO::getName, reqVO.getName())
                .eqIfPresent(CategoryPlatformDO::getPicUrl, reqVO.getPicUrl())
                .eqIfPresent(CategoryPlatformDO::getSort, reqVO.getSort())
                .eqIfPresent(CategoryPlatformDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CategoryPlatformDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(CategoryPlatformDO::getLink, reqVO.getLink())
                .eqIfPresent(CategoryPlatformDO::getIsLink, reqVO.getIsLink())
                .eqIfPresent(CategoryPlatformDO::getIndexDisplay, reqVO.getIndexDisplay())
                .orderByDesc(CategoryPlatformDO::getId));
    }

	default CategoryPlatformDO selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(CategoryPlatformDO::getParentId, parentId, CategoryPlatformDO::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(CategoryPlatformDO::getParentId, parentId);
    }

}